import os
import json

name2path = {}

for subdir, _, files in os.walk('./'):
    for file in files:
        if file.endswith(".png"):
            file_name = file[:-4]
            if file_name in name2path.keys():
                raise Exception("重复的图片名称")
            name2path[file_name] = os.path.join(subdir[2:], file)

json.dump(name2path, open("name2path.json", "w", encoding='utf-8'), ensure_ascii=False)